<?php
$this->breadcrumbs = array(
    'Episodes' => array('index'),
    'Manage',
);

$this->menu = array(
    array('label' => 'List Episode', 'url' => array('index')),
    array('label' => 'Create Episode', 'url' => array('create')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('episode-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h1>Manage Episodes</h1>

<p>
    You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
    or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>

<?php echo CHtml::link('Advanced Search', '#', array('class' => 'search-button btn')); ?>
<div class="search-form" style="display:none">
    <?php
    $this->renderPartial('_search', array(
        'model' => $model,
    ));
    ?>
</div><!-- search-form -->

<?php
$this->widget('bootstrap.widgets.TbGridView', array(
    'id' => 'episode-grid',
    'dataProvider' => $model->search(),
    'filter' => $model,
    'columns' => array(
        array(
            'name' => 'film_id',
            'header' => 'Phim',
            'value' => '$data->film->name_vn',
            'headerHtmlOptions' => array('style' => 'width:300px'),
        ),
        array(
            'name' => 'no_episode',
            'header' => 'Tập',
            'type' => 'html',
            'value' => '"<b>".$data->no_episode."</b>"',
            'headerHtmlOptions' => array('style' => 'width:40px'),
        ),
        array(
            'name' => 'local_id',
            'header' => 'Local',
            'value' => '$data->local->name',
            'class' => 'bootstrap.widgets.TbEditableColumn',
            'headerHtmlOptions' => array('style' => 'width:100px'),
            'editable' => array(
                'type'=>'select',
                'url' => $this->createUrl('episode/updateepisode'),
                'placement' => 'right',
                'inputclass' => 'span2',
                'source'=> CHtml::listData(Local::model()->findAll(), 'id', 'name')
            )
        ),
        array(
            'name' => 'link',
            'header' => 'Link',
            'class' => 'bootstrap.widgets.TbEditableColumn',
            'headerHtmlOptions' => array('style' => 'width:250px'),
            'editable' => array(
                'type' => 'text',
                'url' => $this->createUrl('episode/updateepisode'),
                'placement' => 'right',
                'inputclass' => 'span2',
            )
        ),
        array(
            'name' => 'status',
            'header' => 'Trạng thái',
            'filter' => array('1' => 'Phim bộ', '0' => 'Phim lẻ'),
            'value' => '($data->status=="1")?("Hiển thị"):("Ẩn")',
            'headerHtmlOptions' => array('style' => 'width:80px'),
        ),
        /*
          'no_episode',
          'status',
         */
        array(
            'class' => 'bootstrap.widgets.TbButtonColumn',
            'template' => '{view} {update}',
            'buttons' => array(
                'update' => array(
                    'label' => 'Cập nhật',
                    'options' => array(
                        'target' => '_blank',
                    )
                )
            ),
        ),
    ),
));
?>
